﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using SOM.Control;

namespace SOM.Model
{
    public class CompositionalSpectrum
    {
        public List<CSVector> CSVectorList;
        private MainWindowCtrl mw_control;

        public CompositionalSpectrum(string DirPath, nGrammDictionary Dict, int hamming_dist,MainWindowCtrl ctrl)
        {
            this.mw_control = ctrl;
            CSVector CSVector;
            CSVectorList = new List<CSVector>();
            try
            {
                List<string> fileList = new List<string>(Directory.EnumerateFiles(DirPath));
                int count=0;
                foreach (var file in fileList)
                {
                    count++;
                    CSVector = new CSVector(file, Dict, hamming_dist);
                    CSVectorList.Add(CSVector);
                    ctrl.SetProgressBarValue((int)(((count/ (double)fileList.Count * 100) / 2)));
                }
            }
            catch (UnauthorizedAccessException UAEx)
            {
                //Console.WriteLine(UAEx.Message);
            }
            catch (PathTooLongException PathEx)
            {
                //Console.WriteLine(PathEx.Message);
            }
        
        }
    }
}
